package com.jstide.credit.data.service.biz;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Entity;
import com.jstide.credit.data.service.Algorithm;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;
import java.util.Date;
import java.util.List;
import java.util.Optional;

public class Factor30 extends Algorithm {

    private static final Logger logger = LoggerFactory.getLogger(Factor30.class);

    @Getter
    public final  String name="30";

    //纪律处分信息
    //“警告”-40分；“严重警告”-80分；“撤销党内职务”-100分；“留党察看”-100分；“开除党籍”-120分；取值5年内
    //-120
    @Getter
    public  final String sql ="  select CFCS, CFRQ  from ZRRJLCFXX  where join_id=@joinId   and  CFRQ  >  trunc(sysdate)-(INTERVAL '5' YEAR) ";

    @Override
    public int translate(String rs) {
        return 0;
    }



    @Override
    public int translate(List<Entity> rs) {
        int score = 0;
        if(null!=rs && rs.size()>0){
            score = rs.stream().filter(t-> StrUtil.containsAny(t.getStr("CFCS"), "开除党籍")).count()>0 ? -120:0;
            if(score==0){
                score = rs.stream().filter(t-> StrUtil.containsAny(t.getStr("CFCS"), "留党察看", "撤销党内职务")).count()>0 ? -100:0;
            }
            if(score==0){
                score = rs.stream().filter(t-> StrUtil.containsAny(t.getStr("CFCS"), "严重警告")).count()>0 ? -80:0;
            }
            if(score==0){
                score = rs.stream().filter(t-> StrUtil.containsAny(t.getStr("CFCS"), "警告")).count()>0 ? -40:0;
            }
        }
        return score;
    }
}
